﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Backend.DAL;
using Backend.DTO;

namespace Backend.BLL
{
    public class ListBLL
    {
        private ListDAL aListDAL = new ListDAL();


        #region GenericLists

        public GenericListDTO GetGenericList(int id)
        {
            try
            {
                return aListDAL.GetGenericList(id);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public GenericListDTO GetGenericList(int id, int listType)
        {
            try
            {
                return aListDAL.GetGenericList(id, listType);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public List<GenericListDTO> GetGenericLists(int listType)
        {
            try
            {
                return aListDAL.GetGenericLists(listType);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public List<GenericListDTO> GetGenericLists(int listType, string keyword, int maximumResult = 10)
        {
            if (maximumResult <= 0)
            {
                maximumResult = 1;
            }
            else if (maximumResult > 100)
            {
                maximumResult = 100;
            }

            try
            {
                return aListDAL.GetGenericLists(listType, keyword, maximumResult);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        } 
        
        #endregion


        #region Pharmaceuticals Lists

        public PharmaceuticalsListsDTO GetPharmaceuticalsListsById(int id)
        {
            try
            {
                return aListDAL.GetPharmaceuticalsListsById(id);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public List<PharmaceuticalsListsDTO> GetPharmaceuticalLists()
        {
            try
            {
                return aListDAL.GetPharmaceuticalLists();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public List<PharmaceuticalsListsDTO> GetPharmaceuticalLists(string keyword, int maximumResult = 10)
        {
            if (maximumResult <= 0)
            {
                maximumResult = 1;
            }
            else if (maximumResult > 100)
            {
                maximumResult = 100;
            }

            try
            {
                return aListDAL.GetPharmaceuticalLists(keyword, maximumResult);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        } 
        
        #endregion
    }
}
